﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DataController : MonoBehaviour
{
    public static DataController Instance;
    int _up, _mid, _bottom, _gold;
    [System.NonSerialized]
    public int maxPower1, maxPower2, maxPower3, people, sensitive, maxHP, maxSpeed;

    private void Awake()
    {
        Instance = this;
        up = up;
        mid = mid;
        bottom = bottom;
        PlayerPrefs.SetInt("up", 1);
        PlayerPrefs.SetInt("mid", 1);
        PlayerPrefs.SetInt("bottom", 1);
    }

    public int up
    {
        get
        {
            _up = PlayerPrefs.GetInt("up", 1);
            return _up;
        }
        set
        {
            _up = value;
            PlayerPrefs.SetInt("up", _up);
            maxPower3 = _up * 2 + 100;
            people = _up / 10;
        }
    }

    public int mid
    {
        get
        {
            _mid = PlayerPrefs.GetInt("mid", 1);
            return _mid;
        }
        set
        {
            _mid = value;
            PlayerPrefs.SetInt("mid", _mid);
            maxPower2 = _mid * 5 + 200;
            sensitive = _mid * 10 + 450;
            maxHP = _mid * 15 + 700;
        }
    }

    public int bottom
    {
        get
        {
            _bottom = PlayerPrefs.GetInt("bottom", 1);
            return _bottom;
        }
        set
        {
            _bottom = value;
            PlayerPrefs.SetInt("bottom", _bottom);
            maxPower1 = _bottom * 5 + 200;
            maxSpeed = _bottom * 5 + 450;
        }
    }

    public int gold
    {
        get
        {
            _gold = PlayerPrefs.GetInt("gold", 300);
            return _gold;
        }
        set
        {
            _gold = value;
            PlayerPrefs.SetInt("gold", _gold);
        }
    }
}